package com.kede.api.stand.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/***
 ** @Author:Pr.li
 ** @Description: 配置定时任务线程池，可以多线程执行多个任务
 ** @Date: create in 2023/4/13 9:56
 ***/
@Configuration
public class SchedulerConfig {

    @Bean("virtualThreadPool")
    public Executor virtual(){
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(2);
        executor.setMaxPoolSize(5);
        executor.setQueueCapacity(50);
        executor.setThreadNamePrefix("Virtual");
        executor.setKeepAliveSeconds(30);
        executor.initialize();
        return executor;
    }
}
